package Texas.Test;

import Texas.*;
import Texas.Card.*;
import java.util.*;
import org.junit.*;

public class HandCheckTest {
	private HandChecker handChecker;
	private ArrayList<Card> cards;
	
	@Before public void setUp() {
		handChecker = new HandChecker();
		cards = new ArrayList<Card>();
	}

	@Test public void testHasRoyalFlush() {
		float result = 0;		
		
		cards.add(new Card(CardSuit.HEART, CardRank.KING)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.JACK)); // 2
		cards.add(new Card(CardSuit.CROSS, CardRank.TEN)); // 3
		cards.add(new Card(CardSuit.CROSS, CardRank.NINE)); // 4
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 5
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 6
		cards.add(new Card(CardSuit.HEART, CardRank.SEVEN)); // 7

		result = handChecker.hasRoyalFlush(cards);
		Assert.assertTrue("Result is: " + result , (result >= 8 && result < 9));
	}
	
	@Test public void testHasNotRoyalFlush() {
		float result = 0;
		
		cards.add(new Card(CardSuit.HEART, CardRank.NINE)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.NINE)); // 2
		cards.add(new Card(CardSuit.HEART, CardRank.EIGHT)); // 3
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 4
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.SEVEN)); // 6
		cards.add(new Card(CardSuit.HEART, CardRank.SIX)); // 7

		result = handChecker.hasRoyalFlush(cards);
		Assert.assertFalse("Result is: " + result, (result >= 8 && result < 9));
	}	
	
	@Test public void testHasFourOfAKind() {
		float result = 0;		
		
		cards.add(new Card(CardSuit.HEART, CardRank.NINE)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.NINE)); // 2
		cards.add(new Card(CardSuit.DIAMOND, CardRank.NINE)); // 3
		cards.add(new Card(CardSuit.SPADES, CardRank.NINE)); // 4
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.SEVEN)); // 6
		cards.add(new Card(CardSuit.HEART, CardRank.SEVEN)); // 7

		result = handChecker.hasFourOfAKind(cards);
		Assert.assertTrue("Result is: " + result , (result >= 7 && result < 8));
	}
	
	@Test public void testHasNotFourOfAKind() {
		float result = 0;
		
		cards.add(new Card(CardSuit.HEART, CardRank.NINE)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.NINE)); // 2
		cards.add(new Card(CardSuit.HEART, CardRank.EIGHT)); // 3
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 4
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.SEVEN)); // 6
		cards.add(new Card(CardSuit.HEART, CardRank.SIX)); // 7

		result = handChecker.hasFourOfAKind(cards);
		Assert.assertFalse("Result is: " + result, (result >= 7 && result < 8));
	}	

	@Test public void testHasFullHouse() {
		float result = 0;		
		
		cards.add(new Card(CardSuit.HEART, CardRank.NINE)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.NINE)); // 2
		cards.add(new Card(CardSuit.HEART, CardRank.EIGHT)); // 3
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 4
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.SEVEN)); // 6
		cards.add(new Card(CardSuit.HEART, CardRank.SEVEN)); // 7

		result = handChecker.hasFullHouse(cards);
		Assert.assertTrue("Result is: " + result , (result >= 6 && result < 7));
	}
	
	@Test public void testHasNotFullHouse() {
		float result = 0;
		
		cards.add(new Card(CardSuit.HEART, CardRank.NINE)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.NINE)); // 2
		cards.add(new Card(CardSuit.HEART, CardRank.EIGHT)); // 3
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 4
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.SEVEN)); // 6
		cards.add(new Card(CardSuit.HEART, CardRank.SIX)); // 7

		result = handChecker.hasFullHouse(cards);
		Assert.assertFalse("Result is: " + result, (result >= 6 && result < 7));
	}	
		
	@Test public void testHasFlush() {
		float result = 0;		
		
		cards.add(new Card(CardSuit.CROSS, CardRank.JACK)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.NINE)); // 2
		cards.add(new Card(CardSuit.HEART, CardRank.EIGHT)); // 3
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 4
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.SIX)); // 6
		cards.add(new Card(CardSuit.CROSS, CardRank.FIVE)); // 7

		result = handChecker.hasFlush(cards);
		Assert.assertTrue("Result is: " + result , (result >= 5 && result < 6));
	}
	
	@Test public void testHasNotFlush() {
		float result = 0;
		
		cards.add(new Card(CardSuit.CROSS, CardRank.JACK)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 2
		cards.add(new Card(CardSuit.CROSS, CardRank.SIX)); // 3
		cards.add(new Card(CardSuit.DIAMOND, CardRank.FIVE)); // 4
		cards.add(new Card(CardSuit.HEART, CardRank.FOUR)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.TWO)); // 6
		cards.add(new Card(CardSuit.CROSS, CardRank.TWO)); // 7

		result = handChecker.hasFlush(cards);
		Assert.assertFalse("Result is: " + result, (result >= 5 && result < 6));
	}	
	
	@Test public void testHasStreet() {
		float result = 0;		
		
		cards.add(new Card(CardSuit.CROSS, CardRank.NINE)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 2
		cards.add(new Card(CardSuit.HEART, CardRank.EIGHT)); // 3
		cards.add(new Card(CardSuit.DIAMOND, CardRank.EIGHT)); // 4
		cards.add(new Card(CardSuit.HEART, CardRank.SEVEN)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.SIX)); // 6
		cards.add(new Card(CardSuit.CROSS, CardRank.FIVE)); // 7

		result = handChecker.hasStreet(cards);
		Assert.assertTrue("Result is: " + result , (result >= 4 && result < 5));
	}
	
	@Test public void testHasNotStreet() {
		float result = 0;
		
		cards.add(new Card(CardSuit.CROSS, CardRank.JACK)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 2
		cards.add(new Card(CardSuit.CROSS, CardRank.SIX)); // 3
		cards.add(new Card(CardSuit.DIAMOND, CardRank.FIVE)); // 4
		cards.add(new Card(CardSuit.HEART, CardRank.FOUR)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.TWO)); // 6
		cards.add(new Card(CardSuit.CROSS, CardRank.TWO)); // 7

		result = handChecker.hasThreeOfAKind(cards);
		Assert.assertFalse("Result is: " + result, (result >= 4 && result < 5));
	}	
	
	@Test public void testHasThreeOfAKind() {
		float result = 0;		
		
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 2
		cards.add(new Card(CardSuit.CROSS, CardRank.SIX)); // 3
		cards.add(new Card(CardSuit.DIAMOND, CardRank.SIX)); // 4
		cards.add(new Card(CardSuit.HEART, CardRank.SIX)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.THREE)); // 6
		cards.add(new Card(CardSuit.CROSS, CardRank.TWO)); // 7

		result = handChecker.hasThreeOfAKind(cards);
		Assert.assertTrue("Result is: " + result , (result >= 3 && result < 4));
	}
	
	@Test public void testHasNotThreeOfAKind() {
		float result = 0;
		
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 2
		cards.add(new Card(CardSuit.CROSS, CardRank.SIX)); // 3
		cards.add(new Card(CardSuit.DIAMOND, CardRank.FIVE)); // 4
		cards.add(new Card(CardSuit.HEART, CardRank.FOUR)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.TWO)); // 6
		cards.add(new Card(CardSuit.CROSS, CardRank.TWO)); // 7
		result = handChecker.hasThreeOfAKind(cards);
		Assert.assertFalse("Result is: " + result, (result >= 3 && result < 4));
	}	
	
	@Test public void testHasTwoPair() {
		float result = 0;		
		
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 2
		cards.add(new Card(CardSuit.CROSS, CardRank.FIVE)); // 3
		cards.add(new Card(CardSuit.DIAMOND, CardRank.FIVE)); // 4
		cards.add(new Card(CardSuit.HEART, CardRank.THREE)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.TWO)); // 6
		cards.add(new Card(CardSuit.CROSS, CardRank.TWO)); // 7

		result = handChecker.hasTwoPair(cards);
		Assert.assertTrue("Result is: " + result , (result >= 2 && result < 3));
	}
	
	@Test public void testHasNotTwoPair() {
		float result = 0;
		
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 2
		cards.add(new Card(CardSuit.CROSS, CardRank.SIX)); // 3
		cards.add(new Card(CardSuit.DIAMOND, CardRank.FIVE)); // 4
		cards.add(new Card(CardSuit.HEART, CardRank.FOUR)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.TWO)); // 6
		cards.add(new Card(CardSuit.CROSS, CardRank.TWO)); // 7

		result = handChecker.hasTwoPair(cards);
		Assert.assertFalse( "Result is: " + result, (result >= 2 && result < 3) );
	}
	
	@Test public void testHasOnePair() {
		float result = 0;

		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 2
		cards.add(new Card(CardSuit.CROSS, CardRank.SIX)); // 3
		cards.add(new Card(CardSuit.DIAMOND, CardRank.FIVE)); // 4
		cards.add(new Card(CardSuit.HEART, CardRank.FOUR)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.TWO)); // 6
		cards.add(new Card(CardSuit.CROSS, CardRank.TWO)); // 7
		
		result = handChecker.hasOnePair(cards);
		Assert.assertTrue( "Result is: " + result, (result >= 1 && result < 2) );
	}
	
	@Test public void testHasNotOnePair() {
		float result = 0;
		
		cards.add(new Card(CardSuit.CROSS, CardRank.EIGHT)); // 1
		cards.add(new Card(CardSuit.CROSS, CardRank.SEVEN)); // 2
		cards.add(new Card(CardSuit.CROSS, CardRank.SIX)); // 3
		cards.add(new Card(CardSuit.DIAMOND, CardRank.FIVE)); // 4
		cards.add(new Card(CardSuit.HEART, CardRank.FOUR)); // 5
		cards.add(new Card(CardSuit.DIAMOND, CardRank.THREE)); // 6
		cards.add(new Card(CardSuit.CROSS, CardRank.TWO)); // 7
		
		result = handChecker.hasOnePair(cards);
		Assert.assertFalse( "Result is: " + result, (result >= 1 && result < 2) );
	}
}